<?php
namespace Home\Controller;
use Admin\Model\AerainfoModel;
use Admin\Model\DoctorModel;
use Admin\Model\LinkModel;
use Base\Controller\BaseHomeController;
use Library\BmobSms;
use Think\Controller;
use Admin\Model\LinkStatusModel;
use Think\Verify;

class IndexController extends BaseHomeController {


    /**
     * 进入首页面
     */
    public function index(){
       	if (isMobile()) {
            $this->redirect('/Mobile/index/index');
           }elseif($this->isLogin()){
        	   $this->redirect('DoctorInfo/index');
           }else{
               $this->display();
        }
    }
    /**
     * 验证码
     */
    public function verify()
    {
        $config=C('config');
        ob_clean();
        $verify = new Verify($config);
        $verify->entry();
    }
    /**
     * @param string $province_id
     * 根据省市获取市区的数据
     */
    public function getCityListJson($province_id = '')
    {
        $AerainfoModel= new AerainfoModel();
        $list = $AerainfoModel->relation(false)->field("aerainfo_id,aerainfo_name")->where(array('PARENT_ID'=>$province_id,'status'=>1))->select();
        $this->ajaxReturn($list);
    }
    /**
     * @param string $city_id
     * 根据市区获取县区的数据
     */
    public function getDistrictJson($city_id=""){
        $AerainfoModel= new AerainfoModel();
        $list= $AerainfoModel->relation(false)->field("aerainfo_id,aerainfo_name")->where(array('PARENT_ID'=>$city_id,'status'=>1))->select();
        $this->ajaxReturn($list);
    }
    /***
     * 短信注册
     *
     */
    public  function sendmsg(){
        $phone=I('post.phone');
        $bmobSms = new  BmobSms();
        $res=$bmobSms->sendSmsVerifyCode("$phone", "zb");  //发送短信验证码
        if($res->smsId){
            $data['code']=1;
            $data['msg']='短信发送成功';
            $this->ajaxReturn($data);
        }elseif($res->code==0){
            $data['code']=0;
            $data['msg']='短信发送失败';
            $this->ajaxReturn($data);
        }
    }
}